import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { PriceForm, PriceVO } from '@/api/business/priceCharge/types'

enum Api {
  priceParkList = '/price/park/list',
  priceParkDelete = '/price/park/delete',
  priceParkBatchDelete = '/price/park/batchDelete',
  priceParkAdd = '/price/park/add',
  priceParkEdit = '/price/park/edit',
  priceParkSetting = '/price/park/priceSetting',
  changeStatus = '/price/park/changeStatus',
  priceParkDetail = '/price/park/detail',
  optionSelect = '/price/park/optionSelect',
}

// 获取列表
export const priceParkList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.priceParkList,
    method: 'post',
    data,
  })
}

// 删除
export const priceParkDelete = (data: string) => {
  return request({
    url: Api.priceParkDelete,
    method: 'post',
    data,
  })
}
// 批量删除
export const priceParkBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.priceParkBatchDelete,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const priceParkSave = (data: PriceForm) => {
  return request({
    url: data.id ? Api.priceParkEdit : Api.priceParkAdd,
    method: 'post',
    data,
  })
}

export function changeStatus(id?: string, status?: string) {
  const data = {
    id,
    status,
  }
  return request({
    url: Api.changeStatus,
    method: 'post',
    data,
  })
}

export function priceParkSetting(data: any) {
  return request({
    url: Api.priceParkSetting,
    method: 'post',
    data,
  })
}

// 详情
export const priceParkDetail = (data) => {
  return request({
    url: Api.priceParkDetail,
    method: 'post',
    data,
  })
}

// 获取选择框列表
export const optionSelect = (): AxiosPromise<PriceVO[]> => {
  return request({
    url: Api.optionSelect,
    method: 'post',
    data: {},
  })
}
